package com.sun.service.impl;

import com.sun.dao.UserDaoMapper;
import com.sun.entity.User;
import com.sun.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import static org.springframework.transaction.annotation.Propagation.REQUIRED;

/**
 * @author shkstart
 * @create 2021-09-21 14:27
 */
@Service
@Transactional
public class UserServiceImpl implements UserService {

    @Autowired
    private UserDaoMapper userDaoMapper;

    @Transactional(propagation = REQUIRED)
    @Override
    public User login(User user) {
        User userDB = userDaoMapper.login(user);
        if(userDB!=null){
            return userDB;
        }
        throw  new RuntimeException("登录失败");
    }
}
